package io.adrainty.bolee.framework.seata;

import com.alibaba.cloud.seata.web.SeataHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>SeataWebMvcConfig</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description SeataWebMvcConfig
 * @since 2025/8/22 09:20:42
 */

@Configuration
public class SeataWebMvcConfig implements WebMvcConfigurer {

    /**
     * 解决XID传递问题
     * @return SeataHandlerInterceptor
     */
    @Bean
    public SeataHandlerInterceptor seataHandlerInterceptor(){
        return new SeataHandlerInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(seataHandlerInterceptor()).addPathPatterns("/**");
    }

}
